//app.js

// "tabBar": {
//   "color": "#000000",
//   "backgroundColor": "#ffffff",
//   "selectedColor": "#F2AE05",
//   "list": [
//     {
//       "pagePath": "pages/index/index",
//       "text": "测评",
//       "iconPath": "pages/pic/index.png",
//       "selectedIconPath": "pages/pic/index_s.png"
//     },
//     {
//       "pagePath": "pages/mine/mine",
//       "text": "个人中心",
//       "iconPath": "pages/pic/mine.png",
//       "selectedIconPath": "pages/pic/mine_s.png"
//     }
//   ]
// },


let api = new (require('/utils/api.js'))
App({
  onLaunch: function () {
    console.log(1323123213);
    wx.login({
      success: res => {

        api.wxlogin(res.code, res => {
          this.logininfo = res.data;
          this.token=res.data.Token;
          wx.setStorage({
            key: 'openid',
            data: res.data.openid,
          });
          wx.setStorage({
            key: 'userInfo',
            data: res.data.user,
          })
          wx.setStorage({
            key: 'opengamedate',
            data: res.data.opengamedate,
          })
          wx.setStorage({
            key: 'isnine',
            data: res.data.isnine,
          })
          
        })
      }

      
    })  
},
  badege: function (cart) {
    let cartlength = cart.length;
    cartlength = String(cartlength);
    // console.log(cart, "cart");
    console.log(cartlength,"cartlength");
    if (cartlength > 0) {
      wx.setTabBarBadge({
        index: 3,
        text: cartlength,
      })
    } else {
      wx.removeTabBarBadge({
        index: 3,
      })
    }
  },

  getsetting() {
    api.getsetting(res => {
      if (res.data.issuccess == 1) {
        let setting = res.data.data;
        wx.setStorageSync("setting",setting)
      }
    });
  },
  circleplaysrc:'',
  globalData: {
    userinfo: null
  }
})